<?php

namespace app\yiluqianxing\admin;

use app\admin\controller\Admin;
use app\common\builder\ZBuilder;
use think\Db;

class Yishenhe extends Admin {

    //未审核
    function index(){
        $map = $this->getMap();

        $data=Db::table('dp_ylqx_uploads')
            ->order('id desc')
            ->where($map)
            ->where('status','1')
            ->paginate(10)
            ->each(function ($item,$key){
                $userinf=Db::table('dp_ylqx_user')
                    ->where('openid',$item['openid'])
                    ->find();
                $item['nickname']=$userinf['nickname'];
                $item['avatarurl']=$userinf['avatarurl'];
                $item['path']='https://lightrain.org.cn/uploads/'.$item['path'];

                return $item;
            });

        $js=<<<EOF
            <script type="text/javascript">
                $(".switch").click(function() {
                  location.reload([true])
                })
            </script>
EOF;

        return ZBuilder::make('table')
            ->addColumns([ // 批量添加列
                ['avatarurl', '用户头像','img_url'],
                ['nickname', '用户名'],
                ['path','上传图片','img_url'],
                ['time','上传时间','datetime']
            ])
            ->setTableName('ylqx_uploads')
            ->setExtraJs($js)
            ->addColumn('plus_point', '雨情点')
            ->addColumn('status', '状态', 'yesno')
            ->setRowList($data) // 设置表格数据
            ->fetch();
    }
}